﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using MbUnit.Framework;


namespace Cid.Models
{

	[AssemblyFixture]
	public class TestsSetup
	{
		

		[FixtureSetUp]
		public void Setup()
		{
			Spec.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Cid.mdf;Database=Cid_test;Integrated Security=True;User Instance=True";
			Spec.Adapter = new Cid.Data.Adapter(Spec.ConnectionString);
			ContextProxy.CreateNewContext = () => new CidDataContext(Spec.ConnectionString);

		}


		[FixtureTearDown]
		public void TearDown()
		{
			try
			{
				Spec.Adapter.ExecuteNonQuery("USE MASTER \n ALTER DATABASE [{0}] \n SET SINGLE_USER; exec sp_detach_db '{0}', 'true';".Fuse("Cid_test"), false);
			}catch(System.Exception ex) {
				Console.WriteLine(ex);
			}
		}
	}
}
